package com.ssm.serviceImpl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ssm.dao.AccountEntityMapper;
import com.ssm.entity.AccountEntity;
import com.ssm.service.AccountService;

import myUtils.Utils;

@Service("AccountServiceImpl")
@Transactional
public class AccountServiceImpl implements AccountService {
	
    @Autowired
    private AccountEntityMapper mapper; 
    
	@Override
	public void save(AccountEntity user) {
		 user.setAccountId(Utils.getUUID());
		 mapper.insert(user);
		 return;
	}

	@Override
	public boolean update(AccountEntity user) {
		int result = mapper.updateByPrimaryKey(user);
		if (result == 1) {
			return true;
		} else {
			return false;
		}
	}
	
	@Override
	public AccountEntity validateLogin(String username, String password) {
		AccountEntity account = mapper.findByUsernameAndPassword(username, password);
		return account;
	}

	@Override
	public AccountEntity findById(String id) {
		// TODO Auto-generated method stub
		return null;
	}

}
